package com.weishu.house.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.weishu.common.core.web.controller.BaseController;
import com.weishu.common.core.web.page.TableDataInfo;
import com.weishu.common.security.annotation.PreAuthorize;
import com.weishu.house.entity.PremisesInfo;
import com.weishu.house.service.IPremisesInfoService;
import com.weishu.system.api.domain.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 楼盘信息表 前端控制器
 * </p>
 *
 * @author gao
 * @since 2021-05-25
 */
@RestController
@RequestMapping("premises-info")
public class PremisesInfoController extends BaseController {
    @Autowired
    IPremisesInfoService premisesInfoService;

    @GetMapping("/list")
    @PreAuthorize(hasPermi = "premises:info:list")
    public TableDataInfo list(PremisesInfo premisesInfo)
    {
        startPage();
        QueryWrapper<PremisesInfo> queryWrapper = new QueryWrapper<>();
        if (premisesInfo.getName()!=null){
            queryWrapper.like("name",premisesInfo.getName());
        }
        if (premisesInfo.getPremisesType()!=null){
            queryWrapper.like("premises_type",premisesInfo.getPremisesType());
        }
        List<PremisesInfo> list = premisesInfoService.list(queryWrapper);
        return getDataTable(list);
    }


    @PostMapping("save")
    @PreAuthorize(hasPermi = "premises:info:save")
    public boolean save(@RequestBody PremisesInfo premisesInfo){
        return premisesInfoService.save(premisesInfo);
    }
}
